﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SqlShareAPI;

namespace WebQueryRole
{
    public partial class table_manager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Proxy.ClientProxyTargetType = typeof(AJAXCallbackHandler);      
            List<UserTable> tables = (List<UserTable>)Session[sqlshare_master.USER_TABLES];
            UserSession session = (UserSession)Session[sqlshare_master.USER_SESSION];            
            // populate lists
            tableSelectList.Items.Clear();
            foreach (UserTable table in tables)
            {
                string label = table.tablename;
                if (!table.owner.Equals(session.UserName))
                {
                    label = table.owner + "." + label;
                }
                // incase we need to trim the name
                tableSelectList.Items.Add(new ListItem(label, table.tablename));
            }
        }
    }
}